﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class BuildTool : EditorWindow
{
    [MenuItem("BuiltTool/Apk打包")]
    public static void Init()
    {
        GetWindow<BuildTool>().Show();
    }

    static string[] platforms = new string[] { "Debug", "Test" };
    int platformIndex = 0;
    string companyName = "";
    string productName = "";
    string bundleVersion = "";
    private void OnGUI()
    {
   

        if (GUILayout.Button("Built"))
        {
            string savePath = "";

            string path = string.Format("{0:yy_MM_dd_HH_mm}", DateTime.Now);
            savePath = "D:\\APK" + path + ".apk";


            Debug.Log("暂未适配");

            if (savePath != "")
                BuildPipeline.BuildPlayer(GetEnableEditorScene(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
        }
    }


    public string[] GetEnableEditorScene()
    {
        List<string> scenes = new List<string>();

        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            if (scene.enabled)
            {
                scenes.Add(scene.path);
            }
        }
        return scenes.ToArray();
    }
}
